#ifndef BOOKMANAGEMENT_H
#define BOOKMANAGEMENT_H

#include <QWidget>
#include <QTableView>
#include <QLineEdit>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QMessageBox>
#include <QSqlTableModel>
#include "database.h"
#include "borrowwindow.h"
#include "returnwindow.h"

class BookManagement : public QWidget
{
    Q_OBJECT

public:
    explicit BookManagement(Database *db, QWidget *parent = nullptr);
    ~BookManagement();

private slots:
    void onSearchClicked();
    void onAddBookClicked();
    void onEditBookClicked();
    void onDeleteBookClicked();
    void onBorrowBookClicked();
    void onReturnBookClicked();
    void refreshBookList();

private:
    void setupUI();
    void createConnections();
    void setupTableModel();

    Database *db;
    QTableView *bookTableView;
    QLineEdit *searchEdit;
    QPushButton *searchButton;
    QPushButton *addButton;
    QPushButton *editButton;
    QPushButton *deleteButton;
    QPushButton *borrowButton;
    QPushButton *returnButton;
    QSqlTableModel *bookModel;
};

#endif // BOOKMANAGEMENT_H 
